#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

const int N = 110;
int n, m;
int q[N];
int main()
{
    cin >> n >> m;
    for(int i = 0; i < n; i ++)
    {
        cin >> q[i];
    }
    m %= n;
    if(m != 0)
    {
        reverse(q, q + n);
        reverse(q, q + m);
        reverse(q + m, q + n);
    }

    for(int i = 0;i < n - 1; i ++)
    {
        cout << q[i] << " ";
    }
    cout << q[n - 1];
    return 0;
}